package com.bs.visitservice.controller.user;

import com.bs.visitservice.cache.impl.JedisLoginCache;
import com.bs.visitservice.constant.CacheContant;
import com.bs.visitservice.utils.Result;
import com.bs.visitservice.utils.ThreadLocalUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletRequest;


@RestController
@RequestMapping("/user")
public class UserLogoutController {

    @Autowired
    private JedisLoginCache jedisLoginCache;
    /**
     * 用户端退出
     */
    @RequestMapping(value = "/logout",method = RequestMethod.POST)
    public Result logout(HttpServletRequest request){
        String tokenId = request.getHeader("tokenId");
        boolean isSuc = jedisLoginCache.removeCache(tokenId);
        if(isSuc){
            return Result.success(null);
        }
        return Result.error(null);
    }
}
